interface Person {
  introduce(): void
}

type Constructor = new (...args: any[]) => {}

// 装饰器工厂
function LogInfo(n: number) {
  // return 的是 装饰器
  return function (target: Constructor) {
    target.prototype.introduce = function () {
      for (let i = 0; i < n; i++) {
        console.log(`我的名字是：${this.name}，我的年龄：${this.age}`)   
      }
    }
  }
}

// @LogInfo(3)   // ===> LogInfo(3)(Person) 
@LogInfo(3)
class Person {
  constructor(
    public name: string,
    public age: number
  ) { }

  speak() {
    console.log('你好呀！')
  }
}

const p1 = new Person('张三', 18)
p1.introduce()
